package soundwave.com.demo.list;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;

import soundwave.com.demo.R;
import soundwave.com.demo.activity.Headlines_webview;
import soundwave.com.demo.adpater.Headlines_adapert;
import soundwave.com.demo.test.Headlinecontent_test;

/**
 * Created by xu on 2017/4/29.
 */

public class HeadlinesList extends Activity {
    private TextView back;
    private ListView headlines_list;
    private ArrayList<Headlinecontent_test> headlines;
    private Context context=this;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.headlines_list);
        initView();
        onclik();
        headlines=new ArrayList<>();
        Headlinecontent_test headlinecontent_test1=new Headlinecontent_test();
        headlinecontent_test1.setHeadlines_img(R.mipmap.my);
        headlinecontent_test1.setHeadlines_title("测试一testtesttest");
        headlinecontent_test1.setHeadlines_news("本地新闻");
        headlinecontent_test1.setHeadlines_time("2017年1月7日");
        headlines.add(headlinecontent_test1);

        Headlinecontent_test headlinecontent_test2=new Headlinecontent_test();
        headlinecontent_test2.setHeadlines_img(R.mipmap.integral);
        headlinecontent_test2.setHeadlines_title("测试二testtesttest");
        headlinecontent_test2.setHeadlines_news("外地新闻");
        headlinecontent_test2.setHeadlines_time("2017年1月20日");
        headlines.add(headlinecontent_test2);

        Headlines_adapert adapert=new Headlines_adapert(context,R.layout.headlines_list_content,headlines);
        headlines_list.setAdapter(adapert);
        adapert.notifyDataSetChanged();

    }

    private void initView() {
        back = (TextView) findViewById(R.id.back);
        headlines_list = (ListView) findViewById(R.id.headlines_list);
    }
    private void  onclik(){
        headlines_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                 startActivity(new Intent(context, Headlines_webview.class));
            }
        });
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }
}
